﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Declaratie.Models;

namespace Declaratie.Controllers
{

    public class HomeController : Controller
    {
        ProjectRepository projectRepository;
        public HomeController()
        {
             projectRepository = new ProjectRepository();
        }
   
        public ActionResult Index()
        {
            var projects = projectRepository.GetAllProjects();
            
            ViewBag.Projects = projects;
            return View();
        }

        public ActionResult ProjectDetails(int projectId)
        {
            var project = projectRepository.GetProjectById(projectId);

            return View(project);
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult AddProject()
        {
            return View();
        }

        [HttpPost]
        public JsonResult AddProject(Project project)
        {
            var x = projectRepository.AddProject(project);
            return new JsonResult();
        }
    }
}
